sequenceDiagram
autonumber
actor U as Shopper
participant W as Web App
participant G as API Gateway
participant A as Auth
participant O as Orders
participant I as Inventory
participant P as Payments
participant B as Event Bus
participant N as Notifications
U->>W: Open checkout
W->>G: POST /orders
G->>+A: Validate token
A-->>-G: Claims
alt token invalid
G-->>W: 401
W-->>U: Ask to sign in
else token valid
G->>+O: Create order
O->>+I: Reserve items
loop each line item
I->>I: Check stock
end
alt all reserved
I-->>-O: Reserved
O->>+P: Authorize payment
P-->>-O: Authorized
par publish events
O->>B: OrderCreated
and notify
B->>N: OrderCreated
N-->>U: Confirmation email
and analytics
B->>B: Append to stream
end
O-->>-G: 201 order
else out of stock
I-->>O: Rejected
O->>B: OrderRejected
O-->>G: 409
end
G-->>W: Response
end
Note over W,G: Retries use idempotency keys
opt user watches status
W->>G: GET /orders/42
G->>O: Fetch
O-->>W: Status
end
rect rgba(99, 102, 241, 0.18)
U->>W: Cancel order
W->>O: DELETE /orders/42
O->>P: Refund
P-->>O: Refunded
O->>B: OrderCancelled
end